from paddlers.deploy import Predictor
from paddlers.tasks.utils.visualize import visualize_detection
import numpy as np
class Detect:
    def __init__(self):
        self.predictor = Predictor("./model/detect", use_gpu=True)

    def forward(self, img1):
        pred = self.predictor.predict(img1)
        vis = visualize_detection(
            np.array(img1), pred,
            color=np.asarray([[0, 255, 0]], dtype=np.uint8),
            threshold=0.4, save_dir=None
        )
        return vis
